-- Copyright (c) 2025 Huawei Technologies Co., Ltd.
-- openUBMC is licensed under Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
-- EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
-- MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
-- See the Mulan PSL v2 for more details.

local class = require 'mc.class'

local certificate = class()

function certificate:ctor(chassis_id, mdb_name, cert_info)
    -- 此处需要将C++传递上来的table转换为lua_table
    local cert = {
        ["certificateType"]          = cert_info.certificateType,
        ["certificateUsageType"]     = cert_info.certificateUsageType,
        ["fingerPrint"]              = cert_info.fingerPrint,
        ["fingerPrintHashAlgorithm"] = cert_info.fingerPrintHashAlgorithm,
        ["issuer"]                   = cert_info.issuer,
        ["subject"]                  = cert_info.subject,
        ["serialNumber"]             = cert_info.serialNumber,
        ["signatureAlgorithm"]       = cert_info.signatureAlgorithm,
        ["validNotBefore"]           = cert_info.validNotBefore,
        ["validNotAfter"]            = cert_info.validNotAfter,
        ["certCount"]                = cert_info.certCount,
        ["keyLength"]                = cert_info.keyLength,
        ["commonName"]               = cert_info.commonName,
        ["keyUsage"]                 = cert_info.keyUsage
    }
    self.m_chassis_id = chassis_id
    self.m_mdb_name = mdb_name
    self.m_cert_info = cert
end

return certificate